package com.rz.core.kit;

import com.rz.core.resp.ResultResp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * author: Rui.Zhou
 * date: 2018/7/16
 * Description:
 */
public class RespKit {
    private static Logger logger = LoggerFactory.getLogger(RespKit.class);

    public static ResultResp success(Object data){
        ResultResp resultResp = new ResultResp();
        resultResp.setCode(0);
        resultResp.setMsg("操作成功");
        resultResp.setData(data);
        return resultResp;
    }

    public static ResultResp error(Object data){
        ResultResp resultResp = new ResultResp();
        resultResp.setCode(-1);
        resultResp.setMsg("操作失败");
        resultResp.setData(null);
        return resultResp;
    }

    public static ResultResp error(Object data,String msg){
        ResultResp resultResp = new ResultResp();
        resultResp.setCode(-1);
        resultResp.setMsg(msg);
        resultResp.setData(null);
        logger.error(msg);
        return resultResp;
    }
}